package y23.May;

import java.util.Random;
import java.util.Scanner;

public class Test4 {
    public static void main(String[] args) {
        Random random = new Random();
        int num = random.nextInt(100);
        Scanner sc = new Scanner(System.in);
        int n = 4;
        System.out.println("请输入你要猜的数字");
        while(n > 0){
            int i = sc.nextInt();
            if(i == num){
                System.out.println("恭喜你猜对了");
                break;
            } else if (i < num) {
                System.out.println("很抱歉，猜小了");
            }else {
                System.out.println("很抱歉，猜大了");
            }
            System.out.println("你还剩"+n+"次机会");
            n--;
            System.out.println("请重新输入你要猜的数字");
        }
    }
}
